define(['zepto', 'butterfly/view','../../bsl',
    'text!./camera_video.html'
], function($, View, bsl, camera_video) {
    var me = null;

    var view = View.extend({
        events: {

            // ！！！！ 由于 引入 touch.js 后，tap事件会变成双击，所以 本页面内不能使用tap，用click代替。
            "tap .openDoc" : "openDoc",
            "tap #back" : "back",

      
        },
        render: function() {
            me = this;
        },

        onShow: function() {

            // 绑定自定义事件 滑动切换日历等           


        },
                 v:null,
        loadMedia:function ( src ) {
            v.src = src;
            v.play();
        },
        videoFinished:function () {
            back();
        },
        videoError:function (e) {
            switch (e.target.error.code) {
             case e.target.error.MEDIA_ERR_ABORTED:
               alert('You aborted the video playback.');
               break;
             case e.target.error.MEDIA_ERR_NETWORK:
               alert('A network error caused the video download to fail part-way.');
               break;
             case e.target.error.MEDIA_ERR_DECODE:
               alert('The video playback was aborted due to a corruption problem or because the video used features your browser did not support.');
               break;
             case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
               alert('The video could not be loaded, either because the server or network failed or because the format is not supported.');
               break;
             default:
               alert('An unknown error occurred.');
               break;
           }

            plus.nativeUI.alert( "无效的视频资源", function(){
                this.back();
            } );
        },
        init:function () {
            v = document.getElementById("video");
            //v.onended = videoFinished;
        },
        back : function(e){
            window.history.go(-1);
        },
        openDoc:function(){
             window.butterfly.navigate('/doc/events.html', {
                trigger: true
            });


        },
       
            });
    return view;
});
